<?php

namespace app\controllers;

use Yii;

use app\services\MediaListService;

class MediaListController extends AuthController
{
    public $currentHeader = 'header-resource';
    public $currentNav = 'media-list-nav';
    public $pageTitle = '';

    public function init() {
        parent::init();
        $this->service = new MediaListService();
    }

    public function actionAdspaceList() {
        $this->pageTitle = $this->t('media-list', 'Media List');
        $filter = 'true';
        if (in_array($this->S('user_rank'), ['agent', 'advertiser'])) $filter = '';
        $this->filter = $filter;
        $this->adNetWorks = $this->service->getAllAdNetWork();
        return $this->show();
    }

    public function actionBlackWhiteList() {
        $this->pageTitle = $this->t('media-list', 'Blacklist and Whitelist');
        return $this->show();
    }

    public function actionNewBlackWhite() {
        $this->pageTitle = $this->t('media-list', 'Add New List');
        return $this->show();
    }

    public function actionBlackWhiteEdit() {
        $this->pageTitle = $this->t('media-list', 'Edit List');
        return $this->show();
    }

    public function actionGetAdspaces() {
        $adspaces = $this->service->getAllAdspaces();
        $this->jsonReturn(['data' => $adspaces]);
    }
}// end
